package com.example.steeringwheelseekbar


import android.annotation.SuppressLint
import android.util.Log
import android.view.LayoutInflater
import android.widget.TextView
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.navigation.NavController

@SuppressLint("InflateParams")
@Composable
fun ViewActivity(navController: NavController) {
    val TAG = "ViewActivity"
    Column {
        AndroidView(
            modifier = Modifier
                .fillMaxWidth(),
            factory = { ctx ->
                val view =
                    LayoutInflater.from(ctx).inflate(R.layout.activity_main, null)
                val currentAngle = view.findViewById<TextView>(R.id.seek_bar_progress)
                view.findViewById<SteeringWheelSeekBar>(R.id.seek_bar).setLimitAngle(540, -540)
                    .setListener {
                        Log.e(TAG, "ViewActivity: $it")
                        currentAngle.text = it.toString()
                    }

                view
            }
        )
        Spacer(modifier = Modifier.height(200.dp))
        Button(
            modifier = Modifier.align(alignment = Alignment.CenterHorizontally),
            onClick = { navController.navigate(RouteConfig.ROUTE_COMPOSE_ACTIVITY) }) {
            Text(text = "跳转至compose实现方法", fontSize = 30.sp)
        }
    }
}


